package com.bwie.service.impl;

import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.bwie.Result;
import com.bwie.mapper.OrderMapper;
import com.bwie.mq.MessageProduce;
import com.bwie.pojo.po.OrderPo;
import com.bwie.pojo.po.OrderTypePo;
import com.bwie.service.OrderService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

/**
 * @className: OrderServiceImpl
 * @Description: TODO
 * @version: v1.８.0
 * @author: 杜林涛
 * @date: 2025/6/11 10:41
 */
@Service
public class OrderServiceImpl implements OrderService {
    @Autowired
    OrderMapper orderMapper;
    MessageProduce messageProduce;
    /**
     *  订单列表
     * @return
     */
    @Override
    public PageInfo<OrderPo> oList(OrderPo orderPo) {
        PageHelper.startPage(orderPo.getPageNum(), orderPo.getPageSize());
        List<OrderPo> list= orderMapper.oList(orderPo);
        PageInfo<OrderPo> orderPoPageInfo = new PageInfo<>(list);
        return orderPoPageInfo;
    }

    /**
     *  导出
     * @return
     */
    @Override
    public List<OrderPo> selectStuAll() {
        List<OrderPo> list=orderMapper.selectStuAll();
        return list;
    }
    /**
     *  下拉框
     * @return
     */
    @Override
    public List<OrderTypePo> cc() {
        List<OrderTypePo> list= orderMapper.cc();
        return list;
    }

    /**
     * 新增
     * @param orderPo
     * @return
     */
    @Override
    public Result oAdd(OrderPo orderPo) {
        if(StrUtil.isBlank(orderPo.getStatus())){
            return Result.error("状态不为空");
        }
        if(StrUtil.isBlank(orderPo.getProvince())){
            return Result.error("省份不为空");
        }
        if(StrUtil.isBlank(orderPo.getDealer())){
            return Result.error("经销商名称");
        }
        if(StrUtil.isBlank(orderPo.getOrderNum())){
            return Result.error("订单编号不为空");
        }
        if(StrUtil.isBlank((CharSequence) orderPo.getSubmissionDate())){
            return Result.error("提交日期不为空");
        }
        if(StrUtil.isBlank((CharSequence) orderPo.getPayDate())){
            return Result.error("付款日期日期不为空");
        }
        if(StrUtil.isBlank((CharSequence) orderPo.getShippingDate())){
            return Result.error("发货日期不为空");
        }
        if(StrUtil.isBlank(orderPo.getPayStatus())){
            return Result.error("支付状态不为空");
        }
        orderMapper.oAdd(orderPo);
        return Result.success("添加成功");
    }

    /**
     * 图表
     * @return
     */
    @Override
    public Result<List<Map<String, Object>>> count() {
        List<Map<String,Object>> list=orderMapper.count();
        return Result.success("柱状图",list);
    }

    @Override
    public Result oDel(List<Integer> dek) {
        List<OrderPo> list=orderMapper.oDel(dek);
        return Result.success("成功",list);
    }
}
